package com.frxuexi.lib_base.room

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface LeaveDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun addLeave(leave: Leave):Long

    @Query("select * from leave where uname=:uname  order by startTime desc limit (:page-1)*:size,:page*:size")
    fun getMyLeaves(uname:String,page:Int,size:Int):List<Leave>

    @Query("select count(*) from leave where uname=:uname")
    fun getMyCont(uname:String):Int

    @Query("select * from leave where role='员工' and status='未审核'")
    fun getAllEmp():List<Leave>

    @Update
    fun approveLeave(leave: Leave):Int
}